package com.example.p59;

/*
 * @author Lenovo
 */
import java.io.File;

/**
 * @author Lenovo
 */
public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println("遍历目录");
        File dir = new File("/www/java");
        //要遍历的目录
        visitAllDirsAndFiles(dir);
    }
    public static void visitAllDirsAndFiles(File dir) {
        System.out.println(dir);
        if (dir.isDirectory()) {
            String[] children = dir.list();
            assert children != null;
            for (String child : children) {
                visitAllDirsAndFiles(new File(dir, child));
            }
        }
    }
}